﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GenericKnowledge
{
    public class _01StatckT<T> : IPopable<T>, IPushable<T>
    {
        int position;
        T[] data = new T[100];

        public void Push(T t)
        {
            data[position++] = t;
        }
        //实现了接口中的Pop方法
        public T Pop()
        {
            return data[--position];
        }
        //类索引器
        public T this[int index] => data[index];

        //克隆
        public _01StatckT<T> Clone()
        {
            _01StatckT<T> clone = new _01StatckT<T>();
            return clone;
        }
    }
}
